package org.study.springboot.money;

import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Wine {
    /**
     * 输入起始价格与盈亏比 产出价格
     *
     * @param args
     */
    public static void main(String[] args) {

        String path = "M00/00/00/wKjI5WEHzlKALfLEAAEOZvIhl4Y943.JPG";
        path.indexOf(".");
        String substring = path.substring(path.indexOf(".") + 1).toLowerCase();
        System.out.println(substring);

        String uid = "11111";
        String collect = Arrays.stream(uid.split(",")).distinct().collect(Collectors.joining(";"));
        System.out.println(collect);


        //percent("1.348", "1.350");
    }
    public static void percent(String start,String end){
        //当日涨跌幅计算 （收盘价-昨日收盘价）/昨日收盘价
        BigDecimal startDecimal = new BigDecimal(start);
        BigDecimal endDecimal = new BigDecimal(end);
        // 计算差值
        BigDecimal subtract = endDecimal.subtract(startDecimal);
        System.out.println("" + subtract);
        // 计算比率
        BigDecimal divide = subtract.divide(startDecimal, 4, BigDecimal.ROUND_HALF_UP);

        System.out.println(subtract);
        System.out.println(divide);
        BigDecimal multiply = subtract.multiply(new BigDecimal("1000"));
        System.out.println(multiply);

        NumberFormat percent = NumberFormat.getPercentInstance();
        percent.setMaximumFractionDigits(2);
        System.out.println((percent.format(divide)));
        System.out.println("==============");
    }
}
